import { fileURLToPath, URL } from 'node:url'
import UnoCSS from 'unocss/vite'
import { defineConfig } from 'vite'
import fs from 'fs'
import path from 'path'
import basicSsl from '@vitejs/plugin-basic-ssl'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import vueDevTools from 'vite-plugin-vue-devtools'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [
        vue(),
        vueJsx(),
        vueDevTools(),
        UnoCSS(),
        AutoImport({
            imports: [
                'vue',
                {
                    'naive-ui': ['useDialog', 'useMessage', 'useNotification', 'useLoadingBar']
                }
            ]
        }),
        Components({
            resolvers: [NaiveUiResolver()]
        }),
        basicSsl()
    ],

    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        }
    },

    server: {
        host: 'adminapi.coinpaysg.com', // 使用自定义域名

        port: 5173,
        https: {
            key: fs.readFileSync(path.resolve(__dirname, 'adminapi.coinpaysg.com-key.pem')),
            cert: fs.readFileSync(path.resolve(__dirname, 'adminapi.coinpaysg.com.pem')),
        },
        proxy: {
            // '/api': 'http://10.1.60.31:21201',
            '/api': 'http://192.168.1.7:4444'//'https://adminapi.coinpaysg.com'
            // '/api': 'https://vcc.blockpurse.io',
        }
    },
})
